//
// Created by xili on 2024/8/4 19:18.
// Go big or go home.
//
#include <iostream>

using namespace std;

class Solution {
public:
    int countSegments(string s) {
        int ans = 0;
        for (int i = 0; i < s.size(); i++) {
            if ((i == 0 || s[i - 1] == ' ') && s[i] != ' ') {
                ans++;
            }
        }

        return ans;
    }
};